<template>
  <div class="up-subscribe">
    <div class="up-subscribe__main">
      <div class="up-subscribe__avatar">
        <img class="uc-abscenter" :src="mix_liveInfo.rootOrgInfo.logo || defaultAvatar" alt="头像" />
      </div>
      <div class="up-subscribe__info">
        <p class="up-subscribe__nickname uc-ellipsis">
          {{ mix_liveInfo.rootOrgInfo.name }}
        </p>
        <p v-if="mix_heat" class="up-subscribe__watch"><i></i> {{ hotValue | formatNumber }}</p>
      </div>
    </div>
  </div>
</template>

<script>
import defaultAvatar from '@/static/images/live/default-avatar.png';
import liveInfo from '@/mixins/liveInfo';
import liveSetting from '@/mixins/liveSetting';


export default {
  name: 'UpSubscribe',
  data() {
    return {
      defaultAvatar,
      show: false,
      qualificationShow: false,
      isBusinessLicenseShow: false,
      hotValue: 0
    };
  },

  filters: {
    formatNumber: function (num = 0) {
      return num >= 1e4 ? (Math.floor(num / 1e4 * 100) / 100) + 'w' : num;

    }
  },
  mixins: [liveInfo, liveSetting],
  mounted() {
    console.log(this.mix_liveId, 'liveId')
    this.$tim.onGroup(this.mix_liveId, 'liveHotValueUpdate', (res) => {
      this.hotValue = res.hotValue > this.hotValue ? res.hotValue : this.hotValue;
      console.log(this.hotValue, 'hotValue')
    });
    if (this.mix_official?.pop === 1) {
      this.show = true;
    }
  },
  watch: {
    mix_liveInfo: {
      handler(v) {
        if (v) {
          this.hotValue = v.hotValue > this.hotValue ? v.hotValue : this.hotValue;
        }
      },
      immediate: true, // 进入页面也立即执行
    },
  },
};
</script>

<style lang="scss" scoped>
.up-subscribe {
  position: absolute;
  top: 20px;
  left: 8px;
  z-index: 220;
}

.up-subscribe__watch {
  display: flex;

  i {
    width: 15px;
    height: 15px;
    margin-right: 5px;
    background: url(@/static/images/live/huo@2x.png) no-repeat center;
    background-size: 100%
  }
}

.up-subscribe__main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px 2px 2px;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 18px;
}

.up-subscribe__avatar {
  position: relative;
  width: 32px;
  height: 32px;
  margin-right: 4px;
  overflow: hidden;
  border-radius: 50%;

  img {
    width: 100%;
  }
}

.up-subscribe__info {
  max-width: 15em;
  margin-right: 6px;
  font-size: 14px;

  p {
    line-height: 18px;
  }
}

.up-subscribe__action {
  display: flex;
  align-items: center;
  line-height: 40px;

  button {
    min-width: 52px;
    padding: 4px 6px;
    font-size: 12px;
    line-height: 16px;
    color: #fff;
    text-overflow: inherit;
    word-break: keep-all;
    word-wrap: normal;
    background: linear-gradient(135deg, #1374f6 0%, #6eaafa 100%);
    border: none;
    border-radius: 14px;
  }
}

.up-subscribe__popup-content {
  padding: 30px;
  background: #fff;
  border-radius: 5px;
}

.up-subscribe__qrcode {
  width: 170px;
  height: 170px;
  margin: 0 auto;
}

.up-subscribe__popup-tip {
  margin-top: 20px;
  font-size: 15px;
  font-weight: 400;
  color: #99a9bf;
  text-align: center;
}

.up-subscribe__popup-close {
  display: block;
  margin: 20px auto 0;
  cursor: pointer;
}
</style>
<style lang="scss">
.up-subscribe__popup-container+.van-popup {
  background: transparent;
}
</style>
